"use client";

// 用于获取当前用户关联的组织列表
import { useOrganizationList } from "@clerk/nextjs";
import { Item } from "./item";

export const List = () => {
  const { userMemberships } = useOrganizationList({
    userMemberships: {
      infinite: true, // 列表是没有分页的
    },
  });

  if (!userMemberships.data?.length) return null;
  return (
    <ul>
      {userMemberships.data?.map((mem: any) => {
        const { id, name, imageUrl } = mem.organization;
        return <Item key={id} id={id} name={name} imgUrl={imageUrl} />;
      })}
    </ul>
  );
};
